<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/11/13
  Time: 9:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="jquery.js"></script>
    <style>
        table{
            background-color: aqua;
        }
    </style>
</head>
<body>
<h1>添加直播带货信息</h1>
<form method="post" action="add">
    <table border="1">
        <tr>
            <td>主播姓名：</td>
            <td><input type="text" name="streamer" id="streamer"></td>
        </tr>
        <tr>
            <td>直播平台：</td>
            <td>
                <select name="livePlatform" id="livePlatform">
                    <option value="0">-请选择-</option>
                    <option value="微信">微信</option>
                    <option value="快手">快手</option>
                    <option value="小红书">小红书</option>
                    <option value="视频号">视频号</option>
                    <option value="抖音">抖音</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>带货商品：</td>
            <td><input type="text" name="product" id="product"></td>
        </tr>
        <tr>
            <td>商品价格：</td>
            <td><input type="text" name="price" id="price"></td>
        </tr>
        <tr>
            <td>直播时间：</td>
            <td>
                <input type="text" name="liveTime" id="liveTime">yyyy-MM-dd hh:mm:ss
            </td>
        </tr>
        <tr>
            <td>直播状态：</td>
            <td>
                <input type="radio" name="status" value="1" checked>正常直播
                <input type="radio" name="status" value="0">取消直播
            </td>
        </tr>
        <tr>
            <td>操作：</td>
            <td><input type="submit" value="添加"></td>
        </tr>
    </table>
</form>

<script>
    $("form").submit(res => {
        if ($("#streamer").val() === '' ||
            $("#livePlatform").val() === '' ||
            $("#product").val() === '' ||
            $("#price").val() === '' ||
            $("#liveTime").val() === '' ||
            $("#status").val() === '') {
            alert('请填写完整的信息')
            return false;
        }

        var reg = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/
        if (reg.test($("#liveTime").val())) {
            alert('时间格式不合法，正确格式是yyyy-MM-dd hh:mm:ss')
            return false;
        }
    })
</script>

</body>
</html>
